package com.cqut.familiarity.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.util.Date;
import java.io.Serializable;
import java.util.List;

import com.cqut.familiarity.entity.vo.questionnaireVO.IncompletelyQuestionnaireVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author atao
 * @since 2021-05-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("tb_questionnaire")
@ApiModel(value="Questionnaire对象", description="")
public class Questionnaire implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "ID")
    @TableId(value = "id", type = IdType.ID_WORKER_STR)
    private String id;

    @TableField(exist = false)
    private String user1Id;

    @TableField(exist = false)
    private String user1Name;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "概述")
    private String summary;

    @ApiModelProperty(value = "发布人")
    private String creater;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "修改时间")
    private Date modifyTime;

    @ApiModelProperty(value = "发布后有效期限")
    private Integer validDays;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "是否有效 0:无效 1:有效")
    private String isValid;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "是否匿名  0:匿名 1:不匿名 ")
    private String isAnonymous;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "完成后是否允许查看结果 0:不允许 1:允许")
    private String isLook;

    @ApiModelProperty(value = "重要程度;0:不重要 1：重要")
    private String important;

    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "逻辑删除")
    private String isDeleted;


    @TableField(exist = false)
    @ApiModelProperty(value = "问卷问题")
    private List<Question> questions;


    public Questionnaire(IncompletelyQuestionnaireVO questionnaireVO){
        this.title = questionnaireVO.getTitle();
        this.creater = questionnaireVO.getTitle();
        this.summary = questionnaireVO.getSummary();
        this.validDays = questionnaireVO.getValidDays();
        this.isAnonymous = questionnaireVO.getIsAnonymous();
        this.isLook = questionnaireVO.getIsLook();
    }

}
